//
//  JYTAppointRequest.m
//  JYT_IOS
//
//  Created by nxa-chengjinhui on 2017/1/6.
//  Copyright © 2017年 nxa-yuanguoxiang. All rights reserved.
//

#import "JYTAppointRequest.h"
#import "JYTMineUserClass.h"
@implementation JYTAppointRequest

+(instancetype)shareAppoint{
    static JYTAppointRequest *shareAppoint = nil;
    static dispatch_once_t predicate;
    dispatch_once(&predicate, ^{
        if (shareAppoint==nil) {
            shareAppoint = [[self alloc] init];
        }
    });
    return shareAppoint;
}

-(void)getdata:(NSDictionary *)params completed:(void (^)(BOOL))complete{
    
    JYTHttpClient *client = [JYTHttpClient sharedInstance];
    
    
    BOOL isUsedOffLine = [[JYTUserManager shared] isUsedOffLine];
    
    if (!isUsedOffLine) {
        
        client.urlType = userZoneUrl;
    } else {
        client.urlType = userCenterUrl;
    }
    
    
    client.finishCallbackHandler = ^(id result, NSString *code, NSString *msg) {
        
        NSArray *arr = result[@"data"];
//        NSNumber *number = result[@"PageCount"];
        
//        NSString *pageNo = [NSString stringWithFormat:@"%@", number];
//        
        NSArray *schoolArr = [JYTAppointModel mj_objectArrayWithKeyValuesArray:arr];
        NSLog(@"--%@",schoolArr);
        [JYTMineUserClass shareUserClass].arr = schoolArr;
        
        MyLog(@"result========%@",result);
    
        complete(YES);
    };
    
    client.errorCallbackHandler = ^(NSString * code, NSString * msg) {

        
        MyLog(@"result========++++++++++%@",code);
        complete(NO);
    };
    
    
    NSMutableDictionary *param = [NSMutableDictionary dictionary];
    [param setDictionary:params];
    
    [client post:@"GetDataInfo" withParam:param];
    
}

@end
